﻿@model IList<Node>
@using Stardust.Data.Nodes;
@using NewLife;
@using NewLife.Web;
@using XCode;
@using XCode.Configuration;
@using XCode.Membership;
@using NewLife.Cube;
@{
    var fact = ViewBag.Factory as IEntityFactory;
    var page = ViewBag.Page as Pager;
    var fields = ViewBag.Fields as IList<FieldItem>;
    var set = ViewBag.PageSetting as PageSetting;
    var provider = ManageProvider.Provider;
}
<table class="table table-bordered table-hover table-striped table-condensed">
    <thead>
        <tr>
            @if (set.EnableSelect)
            {
                <th class="text-center" style="width:10px;"><input type="checkbox" id="chkAll" title="全选" /></th>
            }
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("ID"))">编号</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("CityID"))">地区</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Category"))">类别</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Name"))">名称</a></th>
            <th class="text-center" title="编码。NodeKey"><a href="@Html.Raw(page.GetSortUrl("Code"))">编码</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Enable"))">启用</a></th>
            <th class="text-center">历史</th>
            <th class="text-center">数据</th>
            <th class="text-center">诊断</th>
            <th class="text-center">日志</th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Version"))">版本</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("IP"))">本地IP</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("OS"))">操作系统</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("MachineName"))">机器名称</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("UserName"))">用户名称</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Cpu"))">CPU</a></th>
            <th class="text-center" title="内存。单位M"><a href="@Html.Raw(page.GetSortUrl("Memory"))">内存</a></th>
            <th class="text-center" title="应用所在盘，单位M"><a href="@Html.Raw(page.GetSortUrl("TotalSize"))">磁盘</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Logins"))">登录次数</a></th>
            <th class="text-center" title="在线时长。单位秒"><a href="@Html.Raw(page.GetSortUrl("OnlineTime"))">在线时长</a></th>
            <th class="text-center" style="min-width:134px;"><a href="@Html.Raw(page.GetSortUrl("UpdateTime"))">更新时间</a></th>
            <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("UpdateIP"))">更新地址</a></th>
            @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
            {
                <th class="text-center">操作</th>
            }
        </tr>
    </thead>
    <tbody>
        @foreach (var entity in Model)
        {
            var onlineTime = TimeSpan.FromSeconds(entity.OnlineTime);
            <tr>
                @if (set.EnableSelect)
                {
                    <td class="text-center"><input type="checkbox" name="keys" value="@entity.ID" /></td>
                }
                <td class="text-center">@entity.ID</td>
                <td class="text-center">@entity.CityName</td>
                <td class="text-center"><a href="?category=@entity.Category">@entity.Category</a></td>
                <td>@entity.Name</td>
                <td>@entity.Code</td>
                <td class="text-center">
                    <i class="glyphicon glyphicon-@(entity.Enable ? "ok" : "remove")" style="color: @(entity.Enable ? "green" : "red");"></i>
                </td>
                <td><a href="NodeHistory?nodeId=@entity.ID">历史</a></td>
                <td><a href="NodeData?nodeId=@entity.ID">数据</a></td>
                <td><a href="Node/Trace/@entity.ID">诊断</a></td>
                <td><a href="/Admin/Log?category=节点&linkId=@entity.ID">日志</a></td>
                <td title="@entity.CompileTime.ToFullString("")">@entity.Version</td>
                <td title="@entity.IP" style="max-width:200px;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">@entity.IP</td>
                <td title="@entity.OSVersion">@entity.OS</td>
                <td>@entity.MachineName</td>
                <td>@entity.UserName</td>
                <td class="text-right" title="@entity.Processor">@entity.Cpu.ToString("n0")</td>
                <td class="text-right">@entity.Memory.ToString("n0")</td>
                <td class="text-right">@entity.TotalSize.ToString("n0")</td>
                <td class="text-right">@entity.Logins.ToString("n0")</td>
                <td class="text-right">@onlineTime</td>
                <td class="text-center">@entity.UpdateTime.ToFullString("")</td>
                <td class="text-center" title="@entity.UpdateIP.IPToAddress()">@entity.UpdateIP</td>
                @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
                {
                    <td class="text-center">
                        @await Html.PartialAsync("_List_Data_Action", (Object)entity)
                    </td>
                }
            </tr>
        }
    </tbody>
</table>